import router from '@/router/index'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
// 路由白名单列表，把路由添加到这个数组，不用登陆也可以访问
const whiteList = ['/login', '/401','/404', '/500']
NProgress.configure({ showSpinner: false }) // NProgress Configuration
router.beforeEach((to, from, next) => {
  // 开启进度条
  NProgress.start()

  next();
  // const hasToken = localStorage.getItem('token')
  // if (hasToken) {
  //   if (to.path === '/') {
  //     next({
  //       path: '/home'
  //     })
  //   } else {
  //     next()
  //   }
  // } else {
  //   if (whiteList.indexOf(to.path) !== -1) {
  //     next()
  //   } else {
  //     router.push('/login')
  //   }
  // }
})

router.afterEach(() => {
  NProgress.done()
})
